﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;




namespace TheCup.ApiControllers
{
    public class SeasonController : ApiController
    {
        TheCupContext ctx = new TheCupContext();

        public IEnumerable<Season> Get()
        {
            return (from i in ctx.Seasons
                    orderby i.StartDate descending
                    select i);
        }

        public Season Get(DateTime date)
        {
            Season e = new Season();
            return (from i in ctx.Seasons
                 where date >= i.StartDate && date <= i.EndDate
                 select i).FirstOrDefault();
        }

        public Season Get(int id)
        {
            Season e = new Season();
            e = (from i in ctx.Seasons
                 where i.Id == id
                 select i).FirstOrDefault();
            return e;
        }

        // POST api/<controller>
        [Authorize]
        public void Post([FromBody]string value)
        {
        }

        // PUT api/<controller>/5
        [Authorize]
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/<controller>/5
        [Authorize]
        public void Delete(int id)
        {
        }
    }
}